import { useEffect, useState } from "react";
import "./App.css";

function App() {
   const [count, setCount] = useState(0)

   useEffect(() => {
     setInterval(() => {
        console.log(count, 'count'); // 打印的一直是0，useEffect只会执行一次，拿到的是count=0那个时候的闭包
        setCount(count + 1)
     }, 1000)
   }, [])

   return <>
    <div>{count}</div>
   </>
}

export default App;
